

package com.tocean.app;

import com.tocean.app.entity.common.TestPaper;
import com.tocean.app.mapper.common.PaperMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DBUtil {

    private String driver;
    private String url;
    private String username;
    private String password;
    private Connection con;
    private PreparedStatement pstmt;
    private ResultSet rs;


    public void setDriver(String driver) {
this.driver = driver;
}
    public void setUrl(String url) {
this.url = url;
}


    public void setUsername(String username) {
this.username = username;
}
    public void setPassword(String password) {
this.password = password;
}
    public DBUtil() {
        driver="com.mysql.jdbc.Driver";
        url="jdbc:mysql://47.101.137.155:3306/tocean_back?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8&useSSL=false";
        username="root";
        password="wocaowokao123";
    }
    private Connection getConnection(){
        try{
            Class.forName(driver);
            con=DriverManager.getConnection(url,username,password);
        }catch(ClassNotFoundException e){
            e.printStackTrace();
        }catch(SQLException e){
            e.printStackTrace();
        }
    return con;
    }
    @Autowired
    private static PaperMapper paperMapper;
    public static void main(String[] args){
        DBUtil d=new DBUtil();
        System.out.println(d.getConnection());
        TestPaper _testPaper = new TestPaper();

        _testPaper.setPaperName("operateDto.getName()");
        _testPaper.setPaperSubject("operateDto.getSubject()");
        _testPaper.setPaperGrade("operateDto.getGroup()");
        _testPaper.setPaperType("operateDto.getType()");

        paperMapper.insert(_testPaper);



    }
}

